home *** CD-ROM | disk | FTP | other *** search
- Path: newsbf02.news.aol.com!not-for-mail
- From: weatby@aol.com (Weatby)
- Newsgroups: comp.lang.c++
- Subject: Destructors in functions
- Date: 13 Jan 1996 03:40:37 -0500
- Organization: America Online, Inc. (1-800-827-6364)
- Sender: root@newsbf02.news.aol.com
- Message-ID: <4d7r65$dv9@newsbf02.news.aol.com>
- Reply-To: weatby@aol.com (Weatby)
- NNTP-Posting-Host: newsbf02.mail.aol.com
-
- If you pass an object to a function, the language makes a bitwise copy of
- it, local to the function. (Assuming no copy constructor is defined.)
- Then, on the way out, the function calls the user-defined constructor.
-
- This will cause problems if the object has any pointers in it (if they are
- released by the destructor, as they 'should' be).
-
- The question is, why call a destructor on an object for which no
- constructor was called? The compiler has probably put the local copy on
- its stack, and could pop it off on the way out.
-
- Calling a destructor, automatically, for which no constructor was called
- seems to be a non-useful feature. Does anyone know why this was included
- in the language definition?
-
- Thanks.
-
- Bob
-